package cn.xiangyuanpin.service.impl;

import cn.xiangyuanpin.dao.UserDao;
import cn.xiangyuanpin.dao.impl.UserDaoImpl;
import cn.xiangyuanpin.pojo.User;
import cn.xiangyuanpin.service.UserService;

public class UserServiceImpl implements UserService {
private UserDao userDao=new UserDaoImpl();
    @Override
    public void registerUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if(userDao.queryUserByUsername(username)==null){
            return false;
        }
return  true;
    }
}
